package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.WeiXinService;
import com.yixun.qfbao.apidto.base.CommonReqDTO;
import com.yixun.qfbao.apidto.base.CommonResDTO;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.WeixinMsgPushSettingReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReuseSmsSettingHander extends CommonAbstractHander {

    private static Logger logger= LoggerFactory.getLogger(ReuseSmsSettingHander.class);

    @Autowired
    private WeiXinService weiXinService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        WeixinMsgPushSettingReqVo req = (WeixinMsgPushSettingReqVo)reqDto;
        CommonReqDTO weixinMsgPushSettingReq = req.getParams();
        BaseResponseDTO baseResponseDTO = new BaseResponseDTO();
        CommonResDTO resDTO;

        try{
           resDTO = weiXinService.weixinMsgPushSetting(weixinMsgPushSettingReq);
           baseResponseDTO.setResult(resDTO.getResult());
           baseResponseDTO.setErrorMsg(resDTO.getResultMsg());
        }catch (Exception e){
            logger.error("ReuseSmsSettingHander error: {}", e);
            baseResponseDTO.setResult(ResultEnum.FAIL.getNo());
            baseResponseDTO.setErrorMsg("复用短信设置失败");
        }

        return baseResponseDTO;
    }
}
